//
//  ShopViewController.m
//  XiJianChui
//
//  Created by aaa on 16/7/18.
//  Copyright © 2016年 FanShuHan. All rights reserved.
//

#import "ShopViewController.h"
#import "QhStoreCell.h"
static NSInteger const cols = 1;
static CGFloat const margin = 10;
static NSString * const ID = @"storeCell";
#define itemW (QhScreenW - 2 * margin) / cols
#define itemH 180
@interface ShopViewController ()

@end

@implementation ShopViewController

- (instancetype)init
{
    // 创建一个流水布局
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    // 设置cell的尺寸
    layout.itemSize = CGSizeMake(itemW, itemH);
    
    // 设置滚动的方向
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    // 设置cell之间的间距
    layout.minimumInteritemSpacing = margin;
    
    // 行间距
    layout.minimumLineSpacing = margin;
    return [super initWithCollectionViewLayout:layout];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = QhCommonColor;
    self.title = @"店铺";
    self.collectionView.showsVerticalScrollIndicator = NO;
    [self createstylistCollectionView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}
#pragma mark - Create UI
- (void)createstylistCollectionView
{
    self.collectionView.backgroundColor = QhCommonColor;
    [self.collectionView setContentInset:UIEdgeInsetsMake(QhMarin, 0, 0, 0)];
    self.collectionView.bounces = NO;
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.collectionView registerNib:[UINib nibWithNibName:@"QhStoreCell" bundle:nil] forCellWithReuseIdentifier:ID];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 9;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    QhStoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    if (indexPath.row == 1) {
        cell.store.image = [UIImage imageNamed:@"fsh_store2"];
    } else if (indexPath.row == 2) {
        cell.store.image = [UIImage imageNamed:@"fsh_store3"];
    } else if (indexPath.row == 4) {
        cell.store.image = [UIImage imageNamed:@"fsh_store4"];
    }
    return cell;
}
@end
